package com.xjnt.frameworks.plugin.sql.criterion;

import com.xjnt.frameworks.plugin.sql.consts.KeyWord;
import com.xjnt.frameworks.plugin.sql.criterion.expression.BetweenExpression;
import com.xjnt.frameworks.plugin.sql.criterion.expression.InExpression;
import com.xjnt.frameworks.plugin.sql.criterion.expression.LikeExpression;
import com.xjnt.frameworks.plugin.sql.criterion.expression.LogicalExpression;
import com.xjnt.frameworks.plugin.sql.criterion.expression.NotInExpression;
import com.xjnt.frameworks.plugin.sql.criterion.expression.PropExpression;
import com.xjnt.frameworks.plugin.sql.criterion.expression.SimpleExpression;

public class Restrictions {
	
	public static Criterion eq(String columnName, Object value){
		return new SimpleExpression(columnName, value, KeyWord.EQ.getValue());
	}
	
	public static Criterion ne(String columnName, Object value){
		return new SimpleExpression(columnName, value, KeyWord.NE.getValue());
	}
	
	public static Criterion like(String columnName, Object value){
		return new LikeExpression(columnName, value);
	}
	
	public static Criterion gt(String columnName, Object value){
		return new SimpleExpression(columnName, value, KeyWord.GT.getValue());
	}
	
	public static Criterion ge(String columnName, Object value){
		return new SimpleExpression(columnName, value, KeyWord.GE.getValue());
	}
	
	public static Criterion lt(String columnName, Object value){
		return new SimpleExpression(columnName, value, KeyWord.LT.getValue());
	}
	
	public static Criterion le(String columnName, Object value){
		return new SimpleExpression(columnName, value, KeyWord.LE.getValue());
	}
	
	public static Criterion between(String columnName, Object lo, Object hi){
		return new BetweenExpression(columnName, lo, hi);
	}
	
	public static Criterion in(String columnName, Object[] values){
		return new InExpression(columnName, values);
	}
	
	public static Criterion notIn(String columnName, Object[] values){
		return new NotInExpression(columnName, values);
	}
	
	public static LogicalExpression and(Criterion lhs, Criterion rhs){
		return new LogicalExpression(lhs, rhs, KeyWord.AND.getValue());
	}
	
	public static LogicalExpression or(Criterion lhs, Criterion rhs){
		return new LogicalExpression(lhs, rhs, KeyWord.OR.getValue());
	}
	
	public static PropExpression eqProp(String leftColumn, String rightColumn){
		return new PropExpression(leftColumn, rightColumn, KeyWord.EQ.getValue());
	}
	
	public static PropExpression neProp(String leftColumn, String rightColumn){
		return new PropExpression(leftColumn, rightColumn, KeyWord.NE.getValue());
	}
}
